package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.ArchiveDigitizationStat;
import com.ruoyi.system.mapper.ArchiveDigitizationStatMapper;
import com.ruoyi.system.service.ArchiveDigitizationStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 档案数字化统计 Service 实现类
 *
 * @author 你的名字
 */
@Service
public class ArchiveDigitizationStatServiceImpl implements ArchiveDigitizationStatService {
    @Autowired
    private ArchiveDigitizationStatMapper archiveDigitizationStatMapper;

    @Override
    public List<ArchiveDigitizationStat> selectArchiveDigitizationStatList(ArchiveDigitizationStat archiveDigitizationStat) {
        return archiveDigitizationStatMapper.selectArchiveDigitizationStatList(archiveDigitizationStat);
    }

    @Override
    public ArchiveDigitizationStat selectArchiveDigitizationStatById(Long id) {
        return archiveDigitizationStatMapper.selectArchiveDigitizationStatById(id);
    }

    @Override
    public int insertArchiveDigitizationStat(ArchiveDigitizationStat archiveDigitizationStat) {
        return archiveDigitizationStatMapper.insertArchiveDigitizationStat(archiveDigitizationStat);
    }

    @Override
    public int updateArchiveDigitizationStat(ArchiveDigitizationStat archiveDigitizationStat) {
        return archiveDigitizationStatMapper.updateArchiveDigitizationStat(archiveDigitizationStat);
    }

    @Override
    public int deleteArchiveDigitizationStatById(Long id) {
        return archiveDigitizationStatMapper.deleteArchiveDigitizationStatById(id);
    }

    @Override
    public int deleteArchiveDigitizationStatByIds(Long[] ids) {
        return archiveDigitizationStatMapper.deleteArchiveDigitizationStatByIds(ids);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int batchSaveArchiveDigitizationStat(List<ArchiveDigitizationStat> list) {
        // 1. 删除所有旧数据
        archiveDigitizationStatMapper.deleteAllArchiveDigitizationStat();
        // 2. 批量插入新数据
        return archiveDigitizationStatMapper.batchInsertArchiveDigitizationStat(list);
    }
}